///* 送出帐密 */
//$("#checkPWD").click(function() {
// 	 checkProfile();
//});
///* 修改商户资料  */
//$("#modify").click(function() {
//	 modifyProfile();
//});

/* 送出帐密 */
function checkProfile() {
	var postUrl = 'CheckProfile';
	var dataSend = {
		password: $('#password').val()
	};
	$.ajax({
		url : postUrl,
		type : "post",
		dataType : "json",
		data : dataSend,

		success : function(data) {
			console.log(data.message);
			console.log("连接 Servlet 服务成功,"+ postUrl + " request status is " + data.status);
			if(data.status){
				console.log("资料正确");
				
				$('#cId').val(data.cId);
				$('#cName').val(data.cName);
				$('#cAddress').val(data.cAddress);
				$('#user').val(data.user);
				$('#email').val(data.email);
				$('#cPhone').val(data.cPhone);
				$('#cExt').val(data.cExt);
				$('#mobile').val(data.mobile);
				
				$('.formProfile1').toggle();
				$('.formProfile2').toggle();
			}else{
				console.log("资料错误");
				dialog("资料错误",2000);
			}
		},

		error : function(jqXHR, textStatus, errorThrown) {
			dialog("密码错误",2000);
			console.log("return fail");
		}
	});
}

/* 修改商户资料 */
function modifyProfile() {
	var postUrl = 'ModifyProfile';
	var dataSend = {
		cName: $('#cName').val(),
		cAddress: $('#cAddress').val(),
		user: $('#user').val(),
		email: $('#email').val(),
		cPhone: $('#cPhone').val(),
		cExt: $('#cExt').val(),
		mobile: $('#mobile').val(),
		password: $('#password2').val()
	};
	$.ajax({
		url : postUrl,
		type : "post",
		dataType : "json",
		data : dataSend,

		success : function(data) {
			console.log(data.message);
			console.log("连接 Servlet 服务成功,"+ postUrl + " request status is " + data.status);
			if(data.status){
				console.log("资料正确");
				dialog("资料修改成功",2000);
				$(".formProfile2").toggle();
				$(".ModifySuccess").toggle();
				//setTimeout(window.location.assign('manage.jsp'),1000);
				;
			}else{
				console.log("资料错误");
				dialog("资料错误",2000);
			}
		},

		error : function(jqXHR, textStatus, errorThrown) {
			dialog("网路连线异常",2000);
			console.log("return fail");
			console.log("jqXHR:"+jqXHR);
			console.log("textStatus:"+textStatus);
			console.log("errorThrown:"+errorThrown);
		}
	});
}
